package com.bindapp.model;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;

import com.bindapp.BR;
import com.bindapp.R;
import com.bindapp.activity.AboutUsActivity;
import com.bindapp.activity.ShowImgStyleActivity;
import com.bindapp.adapter.MainTab1TwoAdapter;
import com.bindapp.databinding.FragmentTab1twoBinding;
import com.bindapp.listener.RecyclerItemClick;
import com.bindapp.widget.RVItemDecoration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * Created by apple on 2018/6/29.
 */

public class TabOne2Model extends BaseModel {
    private FragmentTab1twoBinding binding;
    private MainTab1TwoAdapter adapter;

    private String[] labellsit;
    private List<Object> datalist=new ArrayList<Object>();
    private Integer[] imglist=new Integer[]{R.drawable.tiyan1,R.drawable.tiyan2,R.drawable.tiyan3,R.drawable.tiyan4};//R.drawable.family

    public TabOne2Model(Context context){
        super(context);
        binding= DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.fragment_tab1two,null,false);
        labellsit=context.getResources().getStringArray(R.array.tab1twolabel);
        datalist.addAll(Arrays.asList(imglist));
        adapter=new MainTab1TwoAdapter(context, datalist,R.layout.item_tab1_two, BR.image,new ItemClick());
        binding.recycleview.setAdapter(adapter);
        binding.recycleview.addItemDecoration(new RVItemDecoration(0));
        binding.recycleview.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    }

    class ItemClick implements RecyclerItemClick {

        @Override
        public void onItemClick(int position) {
            Intent intent=null;
            switch (position){
                case 0:
                    turnToVc(AboutUsActivity.class,new HashMap<String,Object>());
                    break;
                case 1:
                    intent=new Intent(context, ShowImgStyleActivity.class);
                    intent.putExtra("type",0);
                    context.startActivity(intent);
                    break;
                case 2:
                    intent=new Intent(context, ShowImgStyleActivity.class);
                    intent.putExtra("type",1);
                    context.startActivity(intent);
                    break;
                case 3:
                    intent=new Intent(context, ShowImgStyleActivity.class);
                    intent.putExtra("type",2);
                    context.startActivity(intent);
                    break;
            }

        }

        @Override
        public void onItemLongClick(int position) {

        }

        @Override
        public void onMoreClick(View view, int position) {

        }
    }


    @Override
    public FragmentTab1twoBinding getBinding() {
        return binding;
    }
}
